Skip to content

[scanner] fix: test_git_credential_hive.sh mode-notice cases hermetic on per-UID hives (bin/test_git_credential_hive.sh) - #6179

Open
kubestellar-hive[bot] wants to merge 1 commit into
v4from
scanner/fix-cred-helper-test-hermetic
Open

[scanner] fix: test_git_credential_hive.sh mode-notice cases hermetic on per-UID hives (bin/test_git_credential_hive.sh)#6179
kubestellar-hive[bot] wants to merge 1 commit into
v4from
scanner/fix-cred-helper-test-hermetic

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Fix

Makes the mode-notice cases in bin/test_git_credential_hive.sh hermetic on per-UID hives. Claimed ground: bin/test_git_credential_hive.sh only (the helper bin/git-credential-hive.sh is deliberately untouched), plus a changelog.d fragment. Disjoint from the open hermeticity PRs #6120 (dashboard rescan route test) and #6097 (SIGPIPE sweep).

At agent UIDs (>= 2001) the helper derives AGENT from /var/run/hive/uid-map.json — a security property, so an agent cannot spoof HIVE_AGENT — and then reads that real agent's live /tmp/.hive-mode-<agent>. The harness's unique TEST_AGENT and per-case HIVE_AGENT_MODE were silently ignored: on this host (scanner, UID 2008, live mode ISSUES_AND_PRS) the two notice assertions failed; on a host whose live mode is ADVISORY they would pass vacuously.

The harness now prepends a stub id to PATH inside run_helper that reports UID 1000 for exactly id -u and execs the real binary for anything else, forcing the helper down the env-var path each case controls.

Verified: 13 passed / 2 failed before, 15 passed / 0 failed after, on a live per-UID host; bash -n clean.

Fixes #6178


Filed by scanner agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.

— hive: agent=scanner backend=copilot model=claude-fable-5

…metic on per-UID hives

Run as an agent UID (>= 2001), git-credential-hive.sh derives AGENT from
/var/run/hive/uid-map.json - deliberately ignoring HIVE_AGENT, which an
agent could spoof - and then reads that REAL agent's live
/tmp/.hive-mode-AGENT file. The harness's unique TEST_AGENT and
HIVE_AGENT_MODE were silently ignored, so the two mode-notice assertions
tracked the host's deployment state: on this host (scanner, UID 2008,
mode ISSUES_AND_PRS) they failed; on a host whose live mode is ADVISORY
they would pass vacuously for every case.

Stub id(1) on PATH inside run_helper so "id -u" reports a sub-2001 UID,
forcing the helper down the HIVE_AGENT/HIVE_AGENT_MODE path the harness
already controls. Every other id invocation passes through to the real
binary. The helper itself is untouched - the uid-map derivation is a
security property, not the bug.

Fixes #6178

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
@kubestellar-hive kubestellar-hive Bot added the hold label Sep 6, 2026
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 6, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot dco-signoff: yes Indicates the PR's author has signed the DCO. hold size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] test_git_credential_hive.sh mode-notice cases test live host state, not the harness's mode, on per-UID hives

0 participants